package com.acgist.polaris;

/**
 * <p>数据分段</p>
 * 
 * @author acgist
 */
public class Segment {

	/**
	 * <p>数据长度</p>
	 */
	private byte length;
	/**
	 * <p>数据</p>
	 */
	private byte[] data;
	/**
	 * <p>重复次数</p>
	 */
	private int count;
	
	public Segment() {
		super();
	}

	public Segment(byte length, byte[] data) {
		this.length = length;
		this.data = data;
	}

	public byte getLength() {
		return length;
	}

	public byte[] getData() {
		return data;
	}

	public void setLength(byte length) {
		this.length = length;
	}

	public void setData(byte[] data) {
		this.data = data;
	}

	public int getCount() {
		return count;
	}

	public void setCount(int count) {
		this.count = count;
	}
	
	@Override
	public boolean equals(Object obj) {
		if(obj instanceof Segment) {
			final Segment segment = (Segment) obj;
			if(segment.data == this.data) {
				return true;
			}
			if(segment.data == null || this.data == null || segment.data.length != this.data.length) {
				return false;
			}
			for (int index = 0; index < this.data.length; index++) {
				if(segment.data[index] != this.data[index]) {
					return false;
				}
			}
			return true;
		}
		return super.equals(obj);
	}
	
}
